from machine import UART     #　导入串口模块

uart = UART(2, 115200, bits=8, parity=None, rx=13,tx=12, stop=1, timeout=100)       #　初始化一个串口　

while True:
    if uart.any() > 0:
        msg = uart.read()
        print(msg.decode("utf-8"))
        
        if 'on' in msg.decode("utf-8"):
            uart.write(msg.decode("utf-8"))
            print('Turning ON led')
        elif 'off' in msg.decode("utf-8"):
            uart.write(b'Turning OFF led')
            print('Turning OFF led')


